package com.afdor.rws.event.driven.channel.rocketmq.config;

import com.afdor.rws.annotation.extension.Extension;
import com.afdor.rws.annotation.extension.SPI;
import com.afdor.rws.event.driven.channel.rocketmq.utils.RocketMqUtils;
import com.afdor.rws.event.driven.config.EventProducerConfig;
import lombok.Data;
import lombok.NonNull;

/**
 * 生产者参数配置
 *
 * @author 悭梵
 * @date Created in 2018-12-28 14:44
 */
@Data
@SPI(RocketMqUtils.DEFAULT_COMPONENT_CONFIG_EXTENSION_NAME)
@Extension(value = RocketMqUtils.DEFAULT_COMPONENT_CONFIG_EXTENSION_NAME, scope = Extension.Scope.PROTOTYPE, interfaceClass = EventProducerConfig.class)
public class RocketMqEventProducerConfig extends EventProducerConfig<RocketMqEventConfig> {
    /**
     * 生产者核心线程数量
     */
    private int corePoolSize = 4;
    /**
     * 生产者最大线程数量
     */
    private int maxPoolSize = 10;
    /**
     * 生产者队列长度
     */
    private int queueSize = Integer.MAX_VALUE - 1;
    /**
     * 生成者线程名称前缀
     */
    private String threadNamePrefix = "producer-";

    public RocketMqEventProducerConfig() {
    }

    public RocketMqEventProducerConfig(@NonNull final RocketMqEventConfig eventConfig) {
        setEventConfig(eventConfig);
    }

    public String getNamesrvAddr() {
        return getEventConfig().getNamesrvAddr();
    }

    public int getDefaultTopicQueueNums() {
        return getEventConfig().getDefaultTopicQueueNums();
    }

    public boolean isOrderlyConsumer() {
        return getEventConfig().isOrderlyConsumer();
    }

}
